package m202405.d11;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/11 14:45
 */
public class Q560 {

    public int subarraySum(int[] nums, int k) {
        return 0;
    }

    public int subarraySum1(int[] nums, int k) {
        int[] dp = new int[nums.length];
        if (nums[0] == k) {
            dp[0] = 1;
        }
        for (int i = 1; i < nums.length; i++) {
            dp[i] = dp[i - 1] + sum(nums,i,k);
        }
        return dp[nums.length - 1];
    }

    public int sum(int[] nums, int end, int target) {
        int sum = 0;
        int count = 0;
        for (int i = end; i >= 0; i--) {
            sum = sum + nums[i];
            if (sum == target) {
                count++;
            }
        }
        return count;
    }
}
